package com.nulldev.util.web.HttpClient.providers;

import java.io.InputStream;
import java.io.Reader;

import com.nulldev.util.VariableAPI.ArrayUtils;
import com.nulldev.util.web.HttpClient.CachingRequestType;
import com.nulldev.util.web.HttpClient.HttpRequest;
import com.nulldev.util.web.HttpClient.providers.websockets.HttpWebSocketRequest;

public interface HttpClientProvider {

	public HttpRequest<String> getString();

	public HttpRequest<byte[]> getBytes();

	public HttpRequest<InputStream> getStream();

	public HttpRequest<Reader> getReader();

	public HttpWebSocketRequest getSocket();

	public boolean isLegacyCompatible();

	public boolean providesRequests();

	public boolean providesWebSockets();

	public String getID();

	public default ProviderInfo[] providerInfo() {
		return ProviderInfo.EMPTY;
	}

	public default CachingRequestType defaultCachingType() {
		return CachingRequestType.AUTOMATIC;
	}

	public default boolean hasEnum(final ProviderInfo info) {
		return ArrayUtils.contains(providerInfo(), info);
	}

	public static enum ProviderInfo {
		/**
		 * Will run on createTask() invoke. You shouldn't submit this to your executor.
		 */
		WILL_RUN_ON_CT,
		/** Requires Java 11 or newer to function correctly. */
		REQUIRES_MODERN_JAVA,

		;

		private static final ProviderInfo[] EMPTY = new ProviderInfo[0];
	}
}
